import { request } from './request'
import moment from 'moment'
/* 获取歌曲url */
export function _getMusicUrl(id) {
    return request({
        url: '/song/url',
        params: {
            id: id
        }
    })
}

/* 获取歌词 */
export function _getLyric(id) {
    return request({
        url: '/lyric',
        params: {
            id: id,
        }
    })
}
/* 获取歌曲评论 */
export function _musicRecommend(id,limit,offset){
    return request({
        url:'/comment/music',
        params:{
            id:id,
            limit:limit,
            offset: offset,
            timestamp: Date.parse(new Date())
        }
    })
}
/* 对歌单发表评论 回复评论  t: 1 发表 t: 2 回复 */
export  function _pushCommend(cookie,t,id,content,commentId){
    return request({
        url:'/comment',
        params:{
            cookie:cookie,
            t:t,
            type: 0,
            id:id,
            content:content,
            commentId: commentId 
        }
    })
}
/* 获取歌单详情 */
export function _getMusicListDetail(id){
    return request({
        url: '/playlist/detail',
        params: {
            id: id
        }
    })
}
/** 获取歌曲详情 */
export function _getSongsDetail(ids) {
    return request({
        url: '/song/detail',
        params: {
            ids: ids
        }
    })
}
/** 获取歌单评论 */
export function _getPlaylistComment(id, limit, offset) {
    return request({
        url: '/comment/playlist',
        params: {
            id: id,
            limit: limit,
            offset: offset,
            timestamp: Date.parse(new Date())
        }
    })
}
/** 歌曲基础信息 */
export class songDetail_Info{
    constructor(song){
        this.title = song.name;
        this.id = song.id
        this.artist = song.ar[0].name
        this.album = song.al.name
        this.time = moment(song.dt).format('mm:ss')
    }
}
/**歌单基础信息 */
export class musicListDetial_Info{
    constructor(playlist){
        this.img = playlist.coverImgUrl || '';
        this.title=playlist.description;
        this.name=playlist.name;
        this.shareCount=playlist.shareCount;
        this.subscribedCount=playlist.subscribedCount;
        this.playCount=playlist.playCount;
        this.trackCount=playlist.trackCount;
        this.tags=playlist.tags;
        this.createTime=playlist.createTime;
        this.creatorAvatar=playlist.creator.avatarUrl;
        this.creatorName=playlist.creator.nickname;
    }
}
